<template>
	<view>
		<view>
			<button type="warn" @click="saveMsg">异步保存数据</button>
		</view>
		<view>
			<button type="primary" @click="saveMsgSync">同步保存数据</button>
		</view>
		<view>
			<button type="warn" @click="getMsg">获取异步保存数据</button>
		</view>
		<view>
			<button type="primary" @click="getMsgSync">获取同步保存数据</button>
		</view>
		<view>
			<button type="warn" @click="removeMsg">移除异步保存数据</button>
		</view>
		<view>
			<button type="primary" @click="removeMsgSync">移除同步保存数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			saveMsg(){
				uni.setStorage({
					key:"a",
					data:100,
					success() {
						console.log("存储成功")
					}
				})
			}
			,
			saveMsgSync(){
				uni.setStorageSync("b",150)
			},
			getMsg(){
				uni.getStorage({
					key:"a",
					success(res) {
						console.log(res.data)
					}
				})
			},
			getMsgSync(){
				console.log(uni.getStorageSync("b"))
			},
			removeMsg(){
				uni.removeStorage({
					key:"a",
					success() {
						console.log("移除成功")
					}
				})
			},
			removeMsgSync(){
				uni.removeStorageSync("b")
			}
			
		}
	}
</script>

<style>

</style>
